﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using NRules.Fluent;
using NRules.RuleModel;
using NRules;
using System.Collections.Generic;
using Volo.Abp.BackgroundJobs;
using System.Net.Mail;

namespace Himp.TaskScheduling.Samples;

public class SampleAppService : TaskSchedulingAppService, ISampleAppService
{
    private readonly IBackgroundJobManager _backgroundJobManager;

    public SampleAppService(IBackgroundJobManager backgroundJobManager)
    {
        _backgroundJobManager = backgroundJobManager;
    }

    public async Task<SampleDto> GetAsync()
    {
       // await _backgroundJobManager.EnqueueAsync(
       //    new WorkflowArgs
       //    {
       //        Key = "1"
       //    }
       //);

        //var ruleEngine = new RuleEngine();

        //var facts = new List<object>
        //{
        //    "TestInput",
        //    "AnotherInput",
        //    "TestInput111",
        //};

        //ruleEngine.Execute(facts);

        return new SampleDto
        {
            Value = 42
        };
    }

    [Authorize]
    public Task<SampleDto> GetAuthorizedAsync()
    {
        return Task.FromResult(
            new SampleDto
            {
                Value = 42
            }
        );
    }
}
